template <class T>

interface  IExRichEditOleCallback :  public  IRichEditOleCallback
{
public :
	IExRichEditOleCallback();
	virtual   ~ IExRichEditOleCallback();
	int  m_iNumStorages;
	IStorage *  pStorage;
	DWORD m_dwRef;

	virtual  HRESULT STDMETHODCALLTYPE GetNewStorage(LPSTORAGE *  lplpstg);
	virtual  HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid,  void   **  ppvObject);
	virtual  ULONG STDMETHODCALLTYPE AddRef();
	virtual  ULONG STDMETHODCALLTYPE Release();
	virtual  HRESULT STDMETHODCALLTYPE GetInPlaceContext(LPOLEINPLACEFRAME FAR  * lplpFrame,
		LPOLEINPLACEUIWINDOW FAR  * lplpDoc, LPOLEINPLACEFRAMEINFO lpFrameInfo);
	virtual  HRESULT STDMETHODCALLTYPE ShowContainerUI(BOOL fShow);
	virtual  HRESULT STDMETHODCALLTYPE QueryInsertObject(LPCLSID lpclsid, LPSTORAGE lpstg, LONG cp);
	virtual  HRESULT STDMETHODCALLTYPE DeleteObject(LPOLEOBJECT lpoleobj);
	virtual  HRESULT STDMETHODCALLTYPE QueryAcceptData(LPDATAOBJECT lpdataobj, CLIPFORMAT FAR  * lpcfFormat,
		DWORD reco, BOOL fReally, HGLOBAL hMetaPict);
	virtual  HRESULT STDMETHODCALLTYPE ContextSensitiveHelp(BOOL fEnterMode);
	virtual  HRESULT STDMETHODCALLTYPE GetClipboardData(CHARRANGE FAR  * lpchrg, DWORD reco, LPDATAOBJECT FAR  * lplpdataobj);
	virtual  HRESULT STDMETHODCALLTYPE GetDragDropEffect(BOOL fDrag, DWORD grfKeyState, LPDWORD pdwEffect);
	virtual  HRESULT STDMETHODCALLTYPE GetContextMenu(WORD seltyp, LPOLEOBJECT lpoleobj, CHARRANGE FAR  * lpchrg,
		HMENU FAR  * lphmenu);
};

class CRichEditExT : public CWindowImpl<T, CRichEditCtrl>
{
private:
	bool m_bRTF;
	IExRichEditOleCallback *  m_pIRichEditOleCallback;
	BOOL m_bCallbackSet;

public:
 DECLARE_WND_SUPERCLASS(NULL, CRichEditCtrl::GetWndClassName())

 /******************************************************************
 * Function......: Constructor
 * Parameters....: None
 * Returns.......: None
 * Description...: Initializes a class object
 *******************************************************************/
 CRichEditEx()
 {
  m_bRTF = true;
 }

 BOOL PreTranslateMessage(MSG* pMsg)
 {
  pMsg;
  return FALSE;
 }

 BEGIN_MSG_MAP(CRichEditEx)
 END_MSG_MAP()

 /*****************************************************************
 * Function......: SetStreamFormat
 * Parameters....: Formatting flag value
 * Returns.......: None
 * Description...: Sets a formatting flag
 ****************************************************************/
 void SetStreamFormat(bool bRTF)
 {
  m_bRTF = bRTF;
 }

 /*****************************************************************
 * Function......: GetStreamFormat
 * Parameters....: None
 * Returns.......: Formatting flag
 * Description...: Gets a formatting flag
 ***************************************************************/
 bool GetStreamFormat()
 {
  return m_bRTF;
 }


};